<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:include="http://www.w3.org/1999/xhtml">
<head>
    <th:block th:include="include :: header('新增鸡出库')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-ncOutputChicken-add">
        <input type="hidden" name="cforderId" id="cforderId" th:value="${cforderId}"/>
        <input type="hidden" name="requestAmount" id="requestAmount" th:value="${requestAmount}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label">库存：</label>
            <div class="col-sm-8">
                <select name="inputId" id="inputId" class="form-control m-b">
                    <option th:each="chicken:${inputChicken}" th:amount="${chicken.stackAmount}" th:value="${chicken.inputId}" th:text="${chicken.inputCode} +'鸡' +'-('+${chicken.stackAmount}+')只'"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">出库类型：</label>
            <div class="col-sm-8">
                <select name="outputType" required class="form-control m-b"
                        th:with="type=${@dict.getType('outputType')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">供应数量（只）：</label>
            <div class="col-sm-8">
                <input id="outputAmount" name="outputAmount" class="form-control" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">重量（kg）：</label>
            <div class="col-sm-8">
                <input id="outputWeight" name="outputWeight" class="form-control"  type="number" step="0.01" required onkeyup=" value=value.replace(/^(\d*[1-9]\d*\.\d{3})$/,'')">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">供应大鸡数量（只）：</label>
            <div class="col-sm-8">
                <input id="outputAmountBig" name="outputAmountBig" class="form-control" type="number" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')" min="0">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">供应小鸡数量（只）：</label>
            <div class="col-sm-8">
                <input id="outputAmountLittle" name="outputAmountLittle" class="form-control" type="number" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')"  min="0">
            </div>
        </div>
        <!--
        <div class="form-group">
            <label class="col-sm-3 control-label">出库类型 字典：</label>
            <div class="col-sm-8">
                <input id="outputType" name="outputType" class="form-control" type="text">
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">抓鸡时间：</label>
            <div class="col-sm-8">
                <input type="text" style="height: 34px;" data-format="yyyy-MM-dd HH:mm:ss"  th:value="*{#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}" name="catchTime" class="time-input" id="catchTime" data-type="datetime"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">母鸡状态：</label>
            <div class="col-sm-8">
                <select name="chickenStatus" required class="form-control m-b" th:with="type=${@dict.getType('chickenStatus')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">宰杀后成品母鸡标准 ：</label>
            <div class="col-sm-8">
                <select name="isHealthy" required class="form-control m-b" th:with="type=${@dict.getType('isHealthy')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
       <!-- <div class="form-group">
            <label class="col-sm-3 control-label">母鸡状态 1:正常 2：不正常：</label>
            <div class=ol-sm-8">
                <input id="chickenStatus" name="chickenStatus" class="form-control" type="text">
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">宰杀时间：</label>
            <div class="col-sm-8">
                <input type="text" style="height: 34px;" data-format="yyyy-MM-dd HH:mm:ss"  th:value="*{#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}" name="killTime" class="time-input" id="killTime" data-type="datetime"/>
            </div>
        </div>
        <!--<div class="form-group">
            <label class="col-sm-3 control-label">宰杀后成品母鸡标准 1：健康 2：不健康：</label>
            <div class="col-sm-8">
                <input id="isHealthy" name="isHealthy" class="form-control" type="text">
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">宰杀人员：</label>
            <div class="col-sm-8">
                <input id="butcher" name="butcher" class="form-control" type="text" th:value="${name}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">菜房接收时间：</label>
            <div class="col-sm-8">
                <input type="text" style="height: 34px;" data-format="yyyy-MM-dd HH:mm:ss"  th:value="*{#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}" name="receiveTime" class="time-input" id="receiveTime" data-type="datetime"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">菜房接收人员：</label>
            <div class="col-sm-8">
                <input id="receiver" name="receiver" class="form-control" type="text" th:value="${name}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">出库经手人：</label>
            <div class="col-sm-8">
                <input id="outputUser" name="outputUser" class="form-control" type="text" th:value="${name}">
            </div>
        </div>
       <!-- <div class="form-group">
            <label class="col-sm-3 control-label">创建者：</label>
            <div class="col-sm-8">
                <input id="createBy" name="createBy" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">创建时间：</label>
            <div class="col-sm-8">
                <input id="createTime" name="createTime" class="form-control" type="text">
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark"  class="form-control valid" type="text" rows="4"></textarea>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "system/ncOutputChicken"
    $("#form-ncOutputChicken-add").validate({
        rules:{
            xxxx:{
                required:true,
            },
        },
        focusCleanup: true
    });

    function submitHandler() {
        var outputAmount=$("#outputAmount").val();
        var inputamount=$('#inputId').find("option:selected").attr("amount");
        if(parseInt(outputAmount) > parseInt(inputamount)){
            $.modal.alertWarning("所选批次库存不足！");
        }
        else if($("#outputAmountBig").val() != '' || $("#outputAmountLittle").val() != ''){
            if((parseInt($("#outputAmountBig").val())+parseInt($("#outputAmountLittle").val())) != parseInt(outputAmount)){
                $.modal.alertWarning("大小鸡数量之和要与供应数量一致！");
            }
            else{
                if ($.validate.form()) {
                    $.operate.save(prefix + "/addWork", $('#form-ncOutputChicken-add').serialize());
                    parent.location.reload();
                }
            }
        }
        else{
            if ($.validate.form()) {
                $.operate.save(prefix + "/addWork", $('#form-ncOutputChicken-add').serialize());
                parent.location.reload();
            }
       }
    }
</script>
</body>
</html>
